/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package io.renren.modules.sys.controller;

import io.renren.config.security.SecurityUser;
import io.renren.modules.sys.entity.SysUserEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * Controller公共组件
 *
 * @author Mark sunlightcs@gmail.com
 */
public abstract class AbstractController {
	protected Logger logger = LoggerFactory.getLogger(getClass());

	protected SysUserEntity getUser() {
		SecurityUser principal = (SecurityUser) (SecurityContextHolder.getContext().getAuthentication().getPrincipal());

//		return (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
		// todo
		return new SysUserEntity();
	}

	protected Long getUserId() {
		return getUser().getUserId();
	}
}
